package cn.iot.controller.sys;

import cn.iot.common.dto.ResultMsg;
import cn.iot.sys.service.SysFaceRecordService;
import cn.iot.util.DaHuaUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

/**
 * 人脸识别记录
 */
@RestController
@RequestMapping("/sys/faceRecord")
public class SysFaceRecordController {
    @Resource
    private SysFaceRecordService sysFaceRecordService;
    private Logger logger = LoggerFactory.getLogger(getClass());

    /**
     * 人脸闸机流水分页
     * @param map
     * @return
     */
    @PostMapping("getFaceRecordList")
    public ResultMsg getFaceRecordList(@RequestParam Map<String,Object> map){
        logger.info("SysFaceRecordController getFaceRecordList map{}",map);
        ResultMsg msg = sysFaceRecordService.getFaceRecordList(map);
        logger.debug("SysFaceRecordController getFaceRecordList msg{}",msg);
        return msg;
    }

    /**
     * 修改卡规则
     * @return
     */
    @PostMapping("modifyCardTime")
    public ResultMsg modifyCardTime(){
        DaHuaUtil daHuaUtil = new DaHuaUtil();
        ResultMsg msg = daHuaUtil.modifyCardTime("1112", 1112);
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                ResultMsg msg = daHuaUtil.modifyCardTime("1112", 255);
            }
        }, 2 * 60 * 1000); // 2 分钟（10 * 60 * 1000 毫秒）后执行
        return msg;
    }
}
